#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
#include<signal.h>
#include<stdlib.h>

int count=0;

void handler(int signo)
{
  alarm(1);
  //printf("get a sig:%d\n",signo);
  printf("count: %d\n",count);
}

int main()
{
  
  signal(SIGALRM,handler);//注册
  alarm(1);
 
  while(1)
  {
    count++;
    //printf("I am a process!   %d\n",getpid());
    //printf("count: %d\n",count++);
    //sleep(1);
    //raise(2);//自己给自己发信号
    //abort();
  }
  return 0;
}
